home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / PC Card Manager / CIncludes / ConditionalMacros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-13  |  14.3 KB  |  361 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ConditionalMacros.h
  3.  
  4.      Contains:    Set up for compiler independent conditionals
  5.  
  6.      Version:    Universal Interface Files 3.0dx
  7.  
  8.      DRI:        Nick Kledzik
  9.  
  10.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Warning:    *** APPLE INTERNAL USE ONLY ***
  14.                  This file may contain unreleased API's
  15.  
  16.      BuildInfo:    Built by:            SuperMario Build Daemon
  17.                  With Interfacer:    2.0d11   (PowerPC native)
  18.                  From:                ConditionalMacros.i
  19.                      Revision:        45
  20.                      Dated:            3/22/96
  21.                      Last change by:    ngk
  22.                      Last comment:    Add FOR_PTR_BASED_AE
  23.  
  24.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __CONDITIONALMACROS__
  29. #define __CONDITIONALMACROS__
  30.  
  31. /*
  32. ***************************************************************************************************
  33.     UNIVERSAL_INTERFACES_VERSION
  34.     
  35.         0x0300 => version 3.0
  36.         0x0210 => version 2.1
  37.         This conditional did not exist prior to version 2.1
  38. ***************************************************************************************************
  39. */
  40. #define UNIVERSAL_INTERFACES_VERSION 0x0300
  41. /*
  42. ***************************************************************************************************
  43.     GENERATINGPOWERPC        - Compiler is generating PowerPC instructions
  44.     GENERATING68K            - Compiler is generating 68k family instructions
  45.  
  46.         Invariant:
  47.             GENERATINGPOWERPC != GENERATING68K
  48. ***************************************************************************************************
  49. */
  50. #ifdef GENERATINGPOWERPC
  51. #ifndef GENERATING68K
  52. #define GENERATING68K !GENERATINGPOWERPC
  53. #endif
  54. #endif
  55. #ifdef GENERATING68K
  56. #ifndef GENERATINGPOWERPC
  57. #define GENERATINGPOWERPC !GENERATING68K
  58. #endif
  59. #endif
  60. #ifndef GENERATINGPOWERPC
  61. #if defined(powerc) || defined(__powerc)
  62. #define GENERATINGPOWERPC 1
  63. #else
  64. #define GENERATINGPOWERPC 0
  65. #endif
  66. #endif
  67. #ifndef GENERATING68K
  68. #if GENERATINGPOWERPC
  69. #define GENERATING68K 0
  70. #else
  71. #define GENERATING68K 1
  72. #endif
  73. #endif
  74. /*
  75. ***************************************************************************************************
  76.     GENERATING68881            - Compiler is generating mc68881 floating point instructions
  77.     
  78.         Invariant:
  79.             GENERATING68881 => GENERATING68K
  80. ***************************************************************************************************
  81. */
  82. #if GENERATING68K
  83. #if defined(applec) || defined(__SC__)
  84. #ifdef mc68881
  85. #define GENERATING68881 1
  86. #endif
  87. #else
  88. #ifdef __MWERKS__
  89. #if __MC68881__
  90. #define GENERATING68881 1
  91. #endif
  92. #endif
  93. #endif
  94. #endif
  95. #ifndef GENERATING68881
  96. #define GENERATING68881 0
  97. #endif
  98. /*
  99. ***************************************************************************************************
  100.     GENERATINGCFM            - Code being generated assumes CFM calling conventions
  101.     CFMSYSTEMCALLS            - No A-traps.  Systems calls are made using CFM and UPP's
  102.  
  103.         Invariants:
  104.             GENERATINGPOWERPC => GENERATINGCFM
  105.             GENERATINGPOWERPC => CFMSYSTEMCALLS
  106.             CFMSYSTEMCALLS => GENERATINGCFM
  107. ***************************************************************************************************
  108. */
  109. #if GENERATINGPOWERPC || defined(__CFM68K__)
  110. #define GENERATINGCFM 1
  111. #define CFMSYSTEMCALLS 1
  112. #else
  113. #define GENERATINGCFM 0
  114. #define CFMSYSTEMCALLS 0
  115. #endif
  116. /*
  117. ***************************************************************************************************
  118.     One or none of the following BUILDING_≈ conditionals is expected to be set during 
  119.     compilation (e.g. MrC -d BUILDING_FOR_SYSTEM7), the others should be left undefined.
  120.     If none is set, BUILDING_FOR_SYSTEM7_AND_SYSTEM8 is used.
  121.     
  122.         BUILDING_FOR_SYSTEM7                - Code is intended to run on System 7.x machine or earlier .
  123.         BUILDING_FOR_SYSTEM7_AND_SYSTEM8    - Code is intended to run on System 7 or Copland.
  124.         BUILDING_FOR_SYSTEM8                - Code is intended to run on Copland only.
  125.         BUILDING_PREEMPTIVE_CODE            - Code is intended to run as Copland server or driver.
  126.         
  127.     The following conditionals are set up based on which of the BUILDING_≈ flag (above) was specified.
  128.     They are used in throughout the interface files to conditionalize declarations.
  129.     
  130.         FOR_SYSTEM7_ONLY                    - In System 7. Not in Copland.
  131.         FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED    - In System 7. Works in Copland, but there is a better way.
  132.         FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE    - In System 7. In Copland, but only for cooperative tasks.
  133.         FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE    - In System 7. In Copland.
  134.         FOR_SYSTEM8_COOPERATIVE                - Not in System 7.  In Copland, but only for cooperative tasks.
  135.         FOR_SYSTEM8_PREEMPTIVE                - Not in System 7.  In Copland.
  136.         
  137.         FOR_OPAQUE_SYSTEM_DATA_STRUCTURES    - Always true for system 8, but can be set by developer to
  138.                                               true or false for System 7.  When true, the contents of 
  139.                                               many system data structures are removed from the interfaces.
  140.                                               In the future, the Mac OS will have fewer data structures 
  141.                                               shared between applications and the system.  The problem
  142.                                               with shared data is 1) the system has to poll the data
  143.                                               to detect changes made by an application, 2) it prevents
  144.                                               data structures from being changed in the future.
  145.                                               Procedural interface will be used instead.
  146.                                               
  147.         FOR_PTR_BASED_AE                    - This is a temporary fix for Copland DR1.  It is needed to
  148.                                               distinguish between pointer based and handle based AppleEvents.
  149.                                               If you are in the case of BUILDING_FOR_SYSTEM7_AND_SYSTEM8
  150.                                               and want to use new pointer base AppleEvents, you will need to
  151.                                               -d FOR_PTR_BASED_AE on your compiler command line.
  152.         
  153. ***************************************************************************************************
  154. */
  155. #if 0
  156. /* extra if statement is to work around a bug in PPCAsm 1.2a2 */
  157. #elif defined(BUILDING_FOR_SYSTEM7)
  158. #ifndef FOR_OPAQUE_SYSTEM_DATA_STRUCTURES
  159. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 0
  160. #endif
  161. #define FOR_PTR_BASED_AE 0
  162. #define FOR_SYSTEM7_ONLY 1
  163. #define FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED 1
  164. #define FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE 1
  165. #define FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE 1
  166. #define FOR_SYSTEM8_COOPERATIVE 0
  167. #define FOR_SYSTEM8_PREEMPTIVE 0
  168. #elif defined(BUILDING_FOR_SYSTEM7_AND_SYSTEM8)
  169. #ifndef FOR_OPAQUE_SYSTEM_DATA_STRUCTURES
  170. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 1
  171. #endif
  172. #ifndef FOR_PTR_BASED_AE
  173. #define FOR_PTR_BASED_AE 0
  174. #endif
  175. #define FOR_SYSTEM7_ONLY 0
  176. #define FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED 1
  177. #define FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE 1
  178. #define FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE 1
  179. #define FOR_SYSTEM8_COOPERATIVE 1
  180. #define FOR_SYSTEM8_PREEMPTIVE 1
  181. #elif defined(BUILDING_FOR_SYSTEM7_AND_SYSTEM)
  182. /* xlc has a limit of 31 chars for command line defines, so redefine above clipped to 31 chars */
  183. #ifndef FOR_OPAQUE_SYSTEM_DATA_STRUCTURES
  184. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 1
  185. #endif
  186. #ifndef FOR_PTR_BASED_AE
  187. #define FOR_PTR_BASED_AE 0
  188. #endif
  189. #define FOR_SYSTEM7_ONLY 0
  190. #define FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED 1
  191. #define FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE 1
  192. #define FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE 1
  193. #define FOR_SYSTEM8_COOPERATIVE 1
  194. #define FOR_SYSTEM8_PREEMPTIVE 1
  195. #elif defined(BUILDING_FOR_SYSTEM8)
  196. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 1
  197. #define FOR_PTR_BASED_AE 1
  198. #define FOR_SYSTEM7_ONLY 0
  199. #define FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED 0
  200. #define FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE 1
  201. #define FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE 1
  202. #define FOR_SYSTEM8_COOPERATIVE 1
  203. #define FOR_SYSTEM8_PREEMPTIVE 1
  204. #elif defined(BUILDING_PREEMPTIVE_CODE)
  205. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 1
  206. #define FOR_PTR_BASED_AE 1
  207. #define FOR_SYSTEM7_ONLY 0
  208. #define FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED 0
  209. #define FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE 0
  210. #define FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE 1
  211. #define FOR_SYSTEM8_COOPERATIVE 0
  212. #define FOR_SYSTEM8_PREEMPTIVE 1
  213. #else
  214. /* default is BUILDING_FOR_SYSTEM7_AND_SYSTEM8  */
  215. #define FOR_OPAQUE_SYSTEM_DATA_STRUCTURES 1
  216. #ifndef FOR_PTR_BASED_AE
  217. #define FOR_PTR_BASED_AE 0
  218. #endif
  219. #define FOR_SYSTEM7_ONLY 0
  220. #define FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED 1
  221. #define FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE 1
  222. #define FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE 1
  223. #define FOR_SYSTEM8_COOPERATIVE 1
  224. #define FOR_SYSTEM8_PREEMPTIVE 1
  225. #endif
  226. /*
  227. ***************************************************************************************************
  228.  
  229.     OLDROUTINENAMES            - "Old" names for Macintosh system calls are allowed in source code.
  230.                               (e.g. DisposPtr instead of DisposePtr). The names of system routine
  231.                               are now more sensitive to change because CFM binds by name.  In the 
  232.                               past, system routine names were compiled out to just an A-Trap.  
  233.                               Macros have been added that each map an old name to its new name.  
  234.                               This allows old routine names to be used in existing source files,
  235.                               but the macros only work if OLDROUTINENAMES is true.  This support
  236.                               will be removed in the near future.  Thus, all source code should 
  237.                               be changed to use the new names! You can set OLDROUTINENAMES to false
  238.                               to see if your code has any old names left in it.
  239.     
  240.     OLDROUTINELOCATIONS     - "Old" location of Macintosh system calls are used.  For example, c2pstr 
  241.                               has been moved from Strings to TextUtils.  It is conditionalized in
  242.                               Strings with OLDROUTINELOCATIONS and in TextUtils with !OLDROUTINELOCATIONS.
  243.                               This allows developers to upgrade to newer interface files without suddenly
  244.                               all their code not compiling becuase of "incorrect" includes.  But, it
  245.                               allows the slow migration of system calls to more understandable file
  246.                               locations.  OLDROUTINELOCATIONS currently defaults to true, but eventually
  247.                               will default to false.
  248.  
  249. ***************************************************************************************************
  250. */
  251. #ifndef OLDROUTINENAMES
  252. #define OLDROUTINENAMES 0
  253. #endif
  254. #ifndef OLDROUTINELOCATIONS
  255. #define OLDROUTINELOCATIONS 0
  256. #endif
  257. /*
  258. ***************************************************************************************************
  259.     C specific conditionals
  260.  
  261.     CGLUESUPPORTED            - Interface library will support "C glue" functions (function names
  262.                               are: all lowercase, use C strings instead of pascal strings, use 
  263.                               Point* instead of Point).
  264.  
  265.     PRAGMA_ALIGN_SUPPORTED    - Compiler supports "#pragma align=..." directives. The only compilers that
  266.                               can get by without supporting the pragma are old classic 68K compilers
  267.                               that will only be used to compile older structs that have 68K alignment
  268.                               anyways.  
  269.     
  270.     PRAGMA_IMPORT_SUPPORTED    - Compiler supports "#pragma import on/off" directives.  These directives
  271.                               were introduced with the SC compiler which supports CFM 68K.  The directive
  272.                               is used to tell the compiler which functions will be called through a 
  273.                               transition vector (instead of a simple PC-relative offset).  This allows 
  274.                               the compiler to generate better code.  Since System Software functions are
  275.                               implemented as shared libraries and called through transition vectors,
  276.                               all System Software functions are declared with "#pragma import on".
  277.                               
  278.         Invariants:
  279.             PRAGMA_IMPORT_SUPPORTED => CFMSYSTEMCALLS
  280.             GENERATINGPOWERPC => PRAGMA_ALIGN_SUPPORTED
  281. ***************************************************************************************************
  282. */
  283. #ifndef CGLUESUPPORTED
  284. #ifdef THINK_C
  285. #define CGLUESUPPORTED 0
  286. #else
  287. #define CGLUESUPPORTED 1
  288. #endif
  289. #endif
  290. /*
  291.     All PowerPC compilers support pragma align
  292.     For 68K, only Metrowerks and SC 8.0 support pragma align 
  293. */
  294. #ifndef PRAGMA_ALIGN_SUPPORTED
  295.     #if GENERATINGPOWERPC || defined(__MWERKS__) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  296.         #define  PRAGMA_ALIGN_SUPPORTED 1
  297.     #else
  298.         #define  PRAGMA_ALIGN_SUPPORTED 0
  299.     #endif
  300. #endif
  301. /* Currently, only Metowerks CW7 and later, and SC 8.0 or later support pragma import  */
  302. #ifndef PRAGMA_IMPORT_SUPPORTED
  303.     #if ( defined(__MWERKS__) && (__MWERKS__ >= 0x0700) ) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  304.         #define  PRAGMA_IMPORT_SUPPORTED 1
  305.     #else
  306.         #define  PRAGMA_IMPORT_SUPPORTED 0
  307.     #endif
  308. #endif
  309. /*
  310. ***************************************************************************************************
  311.     Set up old "USES..." conditionals to support 1.0 universal interface files
  312.  
  313.     The USESxxx names are old, but cannot be removed yet because source code that
  314.     uses them might still compile, but do the wrong thing. 
  315. ***************************************************************************************************
  316. */
  317. #ifndef USES68KINLINES
  318. #define USES68KINLINES GENERATING68K
  319. #endif
  320. #define USESCODEFRAGMENTS GENERATINGCFM
  321. #define USESROUTINEDESCRIPTORS GENERATINGCFM
  322. /*
  323. ***************************************************************************************************
  324.     The following macros isolate the use of inlines from the routine prototypes.
  325.     A routine prototype will always be followed by on of these inline macros with
  326.     a list of the opcodes to be inlined.  On the 68K side, the appropriate inline
  327.     code will be generated.  On platforms that use code fragments, the macros are
  328.     essentially NOPs.
  329. ***************************************************************************************************
  330. */
  331. #if CFMSYSTEMCALLS
  332. #define ONEWORDINLINE(trapNum)
  333. #define TWOWORDINLINE(w1,w2)
  334. #define THREEWORDINLINE(w1,w2,w3)
  335. #define FOURWORDINLINE(w1,w2,w3,w4)
  336. #define FIVEWORDINLINE(w1,w2,w3,w4,w5)
  337. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
  338. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
  339. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
  340. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
  341. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
  342. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
  343. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
  344. #else
  345. #define ONEWORDINLINE(trapNum) = trapNum
  346. #define TWOWORDINLINE(w1,w2) = {w1,w2}
  347. #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
  348. #define FOURWORDINLINE(w1,w2,w3,w4)  = {w1,w2,w3,w4}
  349. #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
  350. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)     = {w1,w2,w3,w4,w5,w6}
  351. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)      = {w1,w2,w3,w4,w5,w6,w7}
  352. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)      = {w1,w2,w3,w4,w5,w6,w7,w8}
  353. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
  354. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)  = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
  355. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
  356. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
  357. #endif
  358.  
  359. #endif /* __CONDITIONALMACROS__ */
  360.  
  361.